package dal;

import java.awt.Image;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class MapFileStruct {
	
	private String name;
	private String description;
	private Image image;
	private MapStruct map;
	
	//save to file
	public void saveToFile(String filename) throws IOException{
		FileOutputStream fout = new FileOutputStream(filename);
		ObjectOutputStream dout = new ObjectOutputStream(fout);
		dout.writeObject(this);
		dout.close();
	}
	
	//read from file
	public MapFileStruct loadFromFile(String filename) throws IOException{
		MapFileStruct returnValue;
		FileInputStream fout = new FileInputStream(filename);
		ObjectInputStream dout = new ObjectInputStream(fout);
		try {
			returnValue = (MapFileStruct) dout.readObject();
		} catch (ClassNotFoundException e) {
			returnValue = null;
		}
		dout.close();
		return returnValue;
	}
	
	//reading map's standard image from the data structure
	public Image getImage(){
		return image;
	}
	
	//changing map's standard image in the data structure
	public void setImage(Image image){
		this.image = image;
	}
	
	//reading map's description from the data structure
	public String getDescription(){
		return description;
	}
	
	//changing map's description in the data structure
	public void setDescription(String description){
		this.description = description;
	}
	
	//reading the name from the data structure
	public String getName(){
		return name;
	}
	
	//changing the name in the data structure
	public void setName(String name){
		this.name = name;
	}
	
	//reading the map from the data structure
	public MapStruct getMapStruct(){
		return map;
	}
	
	//changing the map in the data structure
	public void setMapStruct(MapStruct map){
		this.map = map;
	}

}
